/**
 */
package com.eplatform.common.utils;

import java.util.Map;
import java.util.Random;

import com.eplatform.modules.sys.entity.SMS;
//import com.taobao.api.ApiException;
//import com.taobao.api.DefaultTaobaoClient;
//import com.taobao.api.TaobaoClient;
//import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
//import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

/**
 * 短信工具类，发送短信
 * @author haolsh
 * @version 2016-08-10
 */
public class SMSUtils {
	
	public static String appUrl="http://gw.api.taobao.com/router/rest";
	public static String appKey="23374403";
	public static String appSecret="810fbc3426d7bfa88da8b2c985e50d44";
	public final static String SESSIONKEY="smsCode";
	/**
	 * 阿里大鱼发送短信接口
	 * @return
	 * @throws ApiException
	 */
	public static Map sendSMS(SMS sms)// throws ApiException
	{
		/*TaobaoClient client = new DefaultTaobaoClient(SMSUtils.appUrl, SMSUtils.appKey, SMSUtils.appSecret);
		AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
		req.setExtend(sms.getExtend());
		req.setSmsType(sms.getSmsType());
		req.setSmsFreeSignName(sms.getSmsFreeSignName());
		req.setSmsParamString("{smscode:'"+sms.getSmscode()+"'}");
		req.setRecNum( sms.getRecNum());
		req.setSmsTemplateCode(sms.getSmsTemplateCode());
		AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
		String code=rsp.getErrorCode();
		if(code==null){
			return ExtData.Result.Success;
		}
		else{
			return ExtData.Result.Error("错误码："+rsp.getErrorCode()+","+rsp.getSubMsg());
		}*/
		return null;
	}
	/**
	 * 随机数字
	 * @param length 长度
	 * @return
	 */
	public static String randCode(int length){
		    Random ne=new Random();
		 	String result="";
		 	for(int i=0;i<length;i++){
		 		 result+=String.valueOf(ne.nextInt(10));
		 		 
		 	}
	        return result;
	}
	public static void main(String[] args){
		System.out.println(randCode(4));
	}
    
}
